package org.ainlolcat.ainscience.statistics;

import org.ainlolcat.ainscience.entity.Entity;

import java.util.Hashtable;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: ain
 * Date: 08.03.12
 * Time: 21:59
 * To change this template use File | Settings | File Templates.
 */
public class StatisticStorage {
    private static StatisticStorage instance = new StatisticStorage();
    Map<Entity,Hashtable<String,StatisticHandler>> stat = new Hashtable();
    private StatisticStorage(){

    }

    public static StatisticStorage getInstance(){
        return instance;
    }

    public void registerHandler(Entity ent, String name, StatisticHandler handler){
        if (stat.containsKey(ent)){
            stat.get(ent).put(name,handler);
        }
        else{
            Hashtable<String , StatisticHandler> temp = new Hashtable<String, StatisticHandler>();
            temp.put(name,handler);
            stat.put(ent, temp);
        }
    }                                              

    public StatisticHandler getHandler(Entity ent, String name){
        return stat.get(ent)==null ? null : stat.get(ent).get(name);
    }
}
